package top.kaoshanji.r2ch07f;

import org.springframework.aop.Pointcut;
import org.springframework.aop.support.ComposablePointcut;
import org.springframework.aop.support.ControlFlowPointcut;
import org.springframework.aop.support.NameMatchMethodPointcut;

/**
 * 代码清单-r2ch07f-257页a：定义一个复合切点
 * @author kaoshanji
 * ^_^
 * create time 2025/5/8 11:06
 */
public class GreetingComposablePointcut {

    public Pointcut getIntersectionPointcut() {
        ComposablePointcut cp = new ComposablePointcut();

        Pointcut p1 = new ControlFlowPointcut(WaiterDelegate.class, "service");
        NameMatchMethodPointcut p2 = new NameMatchMethodPointcut();

        p2.addMethodName("greetTo");

        return cp.intersection(p1).intersection((Pointcut)p2);
    }


}
